<template>
  <div>
    <!--1视图-->
    <button @click="add">弹出</button>
    <span v-for="u in users" class="myclass">
      {{u.date}}--{{u.name}}--{{u.address}}<br>
    </span>
  </div>

</template>

<script>
export default {
  name: "ListView",
  data() {
    return {
      //2属性定义
      users:[]
    }
  }, methods: {
    //3自定义方法
    list(){
      this.axios.get("users.json").then(res=>{
        this.users=res.data;
      })
    },
    add(){
      //遍历集合
      this.users.forEach((row,index)=>{
        if(index%2==0){
          console.log(index+1);
        }
      })
    }
  }, created() {
    //4.钩子函数
    this.list();
  }
}
</script>

<style scoped>
.myclass:hover{
  background-color: green;
}
</style>